package com.czk.model.iterator.practice;

import java.util.Iterator;

/**
 * @Author:ChenZhangKun
 * @Date: 2020/6/17 22:55
 */
public class MarketDevelopmentIterator implements Iterator {
    // 要迭代的部门
    private MarketDepartment marketDepartment;
    // 索引指针
    private int number;
    public MarketDevelopmentIterator(MarketDepartment marketDepartment) {
        this.marketDepartment = marketDepartment;
    }

    @Override
    public boolean hasNext() {
        if (number>marketDepartment.getList().size()-1||marketDepartment.getList().get(number)==null){
            return false;
        }
        return true;
    }

    @Override
    public Object next() {
        Person person=marketDepartment.getList().get(number);
        number++;
        return person;
    }
}
